import {
  addMaterialInfoToCurrentPartApi,
  deleteMaterialInfoToCurrentPartApi,
  getCurrentPartMaterialInfoApi,
  getInsMaterialInfoByDocIdsApi,
  getInsMaterialInfoByDocInfosApi,
} from "../../../util/request/materialLibraryApi";

class MaterialSettingManager {
  getCurrentPartMaterialInfo(params,cb){
    let formData = new FormData();
    formData.append('partDocId',params ?? "");
    getCurrentPartMaterialInfoApi(formData).then(res=>{
      if(res?.status === 200){
        cb(res.data)
      }
    })
  }
  addMaterialItemToCurrentPart(params,cb){
    let formData = new FormData();
    formData.append('partDocId',params.partDocId ?? "");
    formData.append('partDocName',params.partDocName ?? "");
    formData.append('materialNumbers',params.materialNumbers ?? []);
    addMaterialInfoToCurrentPartApi(formData).then(res=>{
      if(res?.status === 200){
        cb(res.data)
      }
    })
  }
  deleteMaterialItemToCurrentPart(params,cb){
    let formData = new FormData();
    formData.append('partDocId',params.partDocId ?? "");
    formData.append('materialNumbers',params.materialNumbers ?? []);
    deleteMaterialInfoToCurrentPartApi(formData).then(res=>{
      if(res?.status === 200){
        cb(res.data)
      }
    })
  }
  //params = [{},{}]
  getInsMaterialInfoByDocInfos(params,cb){
    getInsMaterialInfoByDocInfosApi(params).then(res=>{
      if(res?.status === 200){
        cb(res.data)
      }
    })
  }
}
const materialSettingManager = new MaterialSettingManager();
export { materialSettingManager };